mini.parse();
var form = new mini.Form("form1");

function SetData(data) {
    data = mini.clone(data);
    console.log(data.row);
    if (data.action == "edit") {      //当状态是edit的时候                    

        form.setData(data.row);     //form用setData得到数据添加到框里
    } else if (data.action == "new") {
        Rendering();                  //渲染增加页面空框
        mini.parse();
    }
}

//审核通过
function auditOk() {
    //待审核记录Id
    var applyId = mini.getbyName("carApplyId").getValue();
    //审核标识（ok:通过，pass:未通过）
    var auditOkFlag = mini.getbyName("auditOkFlag").getValue();
    //审核建议
    var auditContent = mini.getbyName("auditContent").getValue();

    var param = {
        applyId: applyId,
        auditFlag: auditOkFlag,
        auditContent: auditContent,
    }

    var params = JSON.stringify(param)
    $.ajax({
        type: "post",
        url: "http://localhost:8080/DSMP/carApply/auditCarApply.do",
        data: params,
        contentType: "application/json",
        success: function (data) {
            mini.alert(data.msg)
            CloseWindow("cancel");
        }
    })
}

//审核未通过
function auditCancle() {

    //待审核记录Id
    var applyId = mini.getbyName("carApplyId").getValue();
    //审核标识（ok:通过，pass:未通过）
    var auditPassFlag = mini.getbyName("auditPassFlag").getValue();
    //审核建议
    var auditContent = mini.getbyName("auditContent").getValue();

    var param = {
        applyId: applyId,
        auditFlag: auditPassFlag,
        auditContent: auditContent,
    }

    var params = JSON.stringify(param)
    $.ajax({
        type: "post",
        url: "http://localhost:8080/DSMP/carApply/auditCarApply.do",
        data: params,
        contentType: "application/json",
        success: function (data) {
            mini.alert(data.msg)
            CloseWindow("cancel");
        }
    })
}


function CloseWindow(action) {
    if (action == "close" && form.isChanged()) {
        if (confirm("数据被修改了，是否先保存？")) {
            return false;
        }
    }
    if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
    else window.close();
}

function onOk(e) {
    SaveData();
}

function onCancel(e) {
    CloseWindow("cancel");
}
function onButtonEdit() {
    mini.open({
        targetWindow: window,
        url:"Departmentlist.html",
        title:"新增车辆信息",
        height:700,
        width:800,
        showMaxButton: true,
        showModal:Boolean,
        allowResize:Boolean,
        setReadOnly:false,
        onload: function () {

        },
        ondestroy: function (action) {
            if(action=="ok"){
                request('0',pager.getPageSize())
            }
        }
    })
}